package com.mywang.weitravel.modules.redlocate;

import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.mywang.weitravel.R;
import com.mywang.weitravel.base.BaseActivity;
import com.mywang.weitravel.base.BaseContract;

import butterknife.BindView;
import butterknife.OnClick;

public class RedLocateActivity extends BaseActivity {

    @BindView(R.id.iv_title_back)
    ImageView ivTitleBack;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_one)
    TextView tvOne;
    @BindView(R.id.tv_two)
    TextView tvTwo;
    @BindView(R.id.red_content)
    FrameLayout redContent;

    private RedFragment redFragment;
    private NumberFragment numberFragment;

    private int currentPage = 1;

    @Override
    protected int getActivityLayoutID() {
        return R.layout.activity_red_locate;
    }

    @Override
    protected void initView() {
        tvTitle.setText("红色寻访");
        redFragment = new RedFragment();
        numberFragment = new NumberFragment();

        getSupportFragmentManager().beginTransaction().replace(R.id.red_content, redFragment).commitAllowingStateLoss();
    }

    @Override
    protected BaseContract.IPresenter initPresenter() {
        return null;
    }

    @OnClick({R.id.iv_title_back, R.id.tv_one, R.id.tv_two})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_title_back:
                finish();
                break;
            case R.id.tv_one:
                if (currentPage == 1) {
                    return;
                }
                currentPage = 1;
                getSupportFragmentManager().beginTransaction().replace(R.id.red_content, redFragment).commitAllowingStateLoss();
                break;
            case R.id.tv_two:
                if (currentPage == 2) {
                    return;
                }
                currentPage = 2;
                getSupportFragmentManager().beginTransaction().replace(R.id.red_content, numberFragment).commitAllowingStateLoss();
                break;
        }
    }
}
